package com.education.platform.api.enums;



import java.math.BigDecimal;

/**
 * 购买豆子的类型
 */
public enum BuyBeanTypeEnum {


    BUY_1(1,BigDecimal.ONE),
    BUY_12(12,new BigDecimal("10")),
    BUY_36(26,new BigDecimal("20")),
    BUY_60(40,new BigDecimal("30")),
    ;

    private Integer beanNumber;
    private BigDecimal costMoney;

     BuyBeanTypeEnum(Integer beanNumber, BigDecimal costMoney){
        this.beanNumber = beanNumber;
        this.costMoney = costMoney;

    }

    public Integer getBeanNumber() {
        return beanNumber;
    }

    public void setBeanNumber(Integer beanNumber) {
        this.beanNumber = beanNumber;
    }

    public BigDecimal getCostMoney() {
        return costMoney;
    }

    public void setCostMoney(BigDecimal costMoney) {
        this.costMoney = costMoney;
    }

    public static boolean checkBuyType(Integer beanNumber,BigDecimal cost){
         for(BuyBeanTypeEnum type:BuyBeanTypeEnum.values()){
             if(type.getBeanNumber().equals(beanNumber)&&type.getCostMoney().compareTo(cost)==0){
                 return true;
             }
         }
        return false;
    }

}
